Skip to content

Implementing gemmi-based mmcif reader (with easy extension to PDB/PDBx and mmJSON)#4712

Open
marinegor wants to merge 144 commits into
MDAnalysis:developfrom
marinegor:feature/mmcif
Open

Implementing gemmi-based mmcif reader (with easy extension to PDB/PDBx and mmJSON)#4712
marinegor wants to merge 144 commits into
MDAnalysis:developfrom
marinegor:feature/mmcif

Conversation

@marinegor

@marinegor marinegor commented Sep 20, 2024

Copy link
Copy Markdown
Contributor

Fixes #2367 and also extends #4303 and solves #5089

Changes made in this Pull Request:

  • uses gemmi library (link) to parse mmcif files
  • adds a class MMCIFReader(base.SingleFrameReaderBase) and class MMCIFParser(TopologyReaderBase) classes for that

As a bonus, this implementation would potentially allow to read any of the gemmi-supported formats (source):

  • mmCIF (PDBx/mmCIF),
  • PDB (with popular extensions),
  • mmJSON

Also, this (with slight modifications) also would allow reading mmcif with multiple models sharing the same topology, as well as more feature-rich parsing of PDBs (the same code without changes can be used for parsing altlocs, charges, etc, from all of these formats).

However, I'm slightly lost on what's to be done next for this PR to be merged, so I'm asking if someone could help me navigate here (tagging @richardjgowers here as author of original PDBx implementation 4303).

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

Developers certificate of origin


📚 Documentation preview 📚: https://mdanalysis--4712.org.readthedocs.build/en/4712/

@pep8speaks

pep8speaks commented Sep 20, 2024

Copy link
Copy Markdown

Hello @marinegor! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 28:80: E501 line too long (84 > 79 characters)
Line 41:80: E501 line too long (85 > 79 characters)
Line 42:80: E501 line too long (93 > 79 characters)
Line 61:80: E501 line too long (104 > 79 characters)
Line 65:80: E501 line too long (87 > 79 characters)
Line 67:80: E501 line too long (107 > 79 characters)

Line 2:24: W291 trailing whitespace
Line 60:80: E501 line too long (111 > 79 characters)
Line 72:80: E501 line too long (123 > 79 characters)
Line 82:80: E501 line too long (122 > 79 characters)
Line 106:80: E501 line too long (108 > 79 characters)
Line 113:80: E501 line too long (80 > 79 characters)
Line 128:80: E501 line too long (91 > 79 characters)
Line 175:80: E501 line too long (126 > 79 characters)
Line 185:80: E501 line too long (125 > 79 characters)
Line 224:80: E501 line too long (126 > 79 characters)
Line 242:80: E501 line too long (140 > 79 characters)
Line 281:80: E501 line too long (87 > 79 characters)
Line 292:80: E501 line too long (90 > 79 characters)

Line 56:80: E501 line too long (80 > 79 characters)
Line 57:80: E501 line too long (84 > 79 characters)

Line 335:26: W292 no newline at end of file

Line 48:80: E501 line too long (103 > 79 characters)
Line 81:80: E501 line too long (80 > 79 characters)
Line 97:80: E501 line too long (86 > 79 characters)
Line 271:80: E501 line too long (90 > 79 characters)
Line 340:80: E501 line too long (104 > 79 characters)
Line 387:80: E501 line too long (83 > 79 characters)
Line 436:80: E501 line too long (80 > 79 characters)
Line 463:80: E501 line too long (80 > 79 characters)
Line 481:80: E501 line too long (80 > 79 characters)
Line 493:80: E501 line too long (80 > 79 characters)
Line 494:80: E501 line too long (80 > 79 characters)
Line 497:80: E501 line too long (83 > 79 characters)
Line 498:80: E501 line too long (86 > 79 characters)
Line 546:80: E501 line too long (82 > 79 characters)
Line 547:80: E501 line too long (82 > 79 characters)
Line 549:80: E501 line too long (88 > 79 characters)
Line 551:80: E501 line too long (88 > 79 characters)
Line 552:80: E501 line too long (81 > 79 characters)
Line 777:80: E501 line too long (81 > 79 characters)
Line 778:80: E501 line too long (87 > 79 characters)
Line 779:80: E501 line too long (84 > 79 characters)
Line 780:80: E501 line too long (85 > 79 characters)
Line 781:80: E501 line too long (83 > 79 characters)

Comment last updated at 2024-10-25 11:17:29 UTC

@github-actions

github-actions Bot commented Sep 20, 2024

Copy link
Copy Markdown

Linter Bot Results:

Hi @marinegor! Thanks for making this PR. We linted your code and found the following:

Some issues were found with the formatting of your code.

Code Location Outcome
main package ⚠️ Possible failure
testsuite ⚠️ Possible failure

Please have a look at the darker-main-code and darker-test-code steps here for more details: https://github.com/MDAnalysis/mdanalysis/actions/runs/11148966346/job/30986736623


Please note: The black linter is purely informational, you can safely ignore these outcomes if there are no flake8 failures!

@richardjgowers richardjgowers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far, will require a small test file to check reader/parser halves.

Comment thread package/MDAnalysis/coordinates/MMCIF.py Outdated
Comment thread package/MDAnalysis/topology/MMCIFParser.py Outdated
Comment thread package/MDAnalysis/topology/MMCIFParser.py Outdated
Comment thread package/MDAnalysis/topology/MMCIFParser.py Outdated
Comment thread package/pyproject.toml Outdated

@BradyAJohnston BradyAJohnston left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone through and addressed tweaks and cleanup.

I did a minor refactor of the atom loop into something a bit more readable.

Should be ready to go now!

@BradyAJohnston BradyAJohnston requested a review from orbeckst April 28, 2026 08:11

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have minor doc fix/change requests. Looks good to go from the technical side. There are some explicit python loops that look slow but as the comments say, check back when the gemmi Python API gives access to flat structures.

Comment thread package/MDAnalysis/coordinates/MMCIF.py Outdated
Comment thread package/MDAnalysis/coordinates/MMCIF.py Outdated
Comment thread package/MDAnalysis/coordinates/MMCIF.py Outdated
Comment thread package/MDAnalysis/coordinates/MMCIF.py Outdated
Comment thread package/MDAnalysis/coordinates/MMCIF.py
Comment thread package/MDAnalysis/coordinates/MMCIF.py Outdated
Comment thread package/MDAnalysis/topology/MMCIFParser.py Outdated
Comment thread package/MDAnalysis/topology/MMCIFParser.py
Comment thread package/MDAnalysis/topology/PDBParser.py Outdated

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my comments; all good from my side.

(I left optional suggestions, which are really flavor-to-taste, whatever you think works better.)

Comment thread package/MDAnalysis/coordinates/MMCIF.py Outdated
Comment thread package/MDAnalysis/topology/MMCIFParser.py Outdated
Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>
@BradyAJohnston

Copy link
Copy Markdown
Member

@IAlibay If we are are headed for a new release, would love to get this PR merged & part of if if you could take a final look.

@IAlibay IAlibay added this to the 2.11 milestone May 27, 2026
@orbeckst orbeckst mentioned this pull request May 30, 2026
8 tasks
@ianmkenney

Copy link
Copy Markdown
Member

+1 on seeing this merged into the next release!

@orbeckst orbeckst assigned orbeckst and unassigned richardjgowers and hmacdope Jul 12, 2026
@orbeckst

Copy link
Copy Markdown
Member

@IAlibay your comment had been addressed and the gemmi reader is also tested in Windows on azure. Could you updated your review, please? Otherwise I'll dismiss it in a day in an effort to merge this important new feature.

(I am not sure what the linter wants, I'll try to make it happy.)

@IAlibay

IAlibay commented Jul 12, 2026

Copy link
Copy Markdown
Member

@IAlibay your comment had been addressed and the gemmi reader is also tested in Windows on azure. Could you updated your review, please? Otherwise I'll dismiss it in a day in an effort to merge this important new feature.

(I am not sure what the linter wants, I'll try to make it happy.)

@orbeckst can you give me until Tuesday please? I agree it's an important feature and I do want to review it, however there's some other high priority items within MDAnalysis that needs addressing first.

Either way, I'm not going to be releasing a be version of MDAnalysis until after the 17th - so it not being merged until then isn't an issue.

@orbeckst

Copy link
Copy Markdown
Member

Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDBx/mmCIF Reader/Topology Reader